﻿
GY.Bill.Other = {
    CheckInput: function () {
        var remark = $("#txtRemark").val();

        var msg = "";

        if (remark == "") {
            msg = "请填写备注";
            return msg;
        }

        return msg;
    },
    GetBillModel: function () {
        var model = {
            BillType: $("#divMain").attr("data-type"),
            Remark: $("#txtRemark").val()
        }
        return model;
    },
    //保存票据
    SaveBill: function () {
        $.ajax({
            type: "Post",
            url: $("#divMain").attr("data-url"),
            data: GY.Bill.Other.GetBillModel(),
            async: false,
            dataType: "json",
            success: function (result) {
                if (result.code == 1) {
                    window.location.href = $("#divMain").attr("data-done-url").replace("ConsultId", result.data).replace("ConsultId", result.data);
                }
            }
        });
    }
};
(function () {
    $(function () {
        //立即发布
        $("#btnQuote").on("tap", function () {
            var msg = GY.Bill.Other.CheckInput();
            if (msg != "") {
                //显示错误消息
                ShowTip(msg);
                return;
            } else {
                fnShade($(".shade"));
                $(".shade").show();
                $(".mask_tip").show();
            }
        });


        //发布票据
        $("#btnSure").on("tap", function () {
            var flag = GY.Bill.Common.SaveCheck($(this));

            if (flag) {
                GY.Bill.Other.SaveBill();
            }
        });

        //修改用户信息并保存报价信息
        $("#btnSaveUserOffer").on("tap", function () {
            var flag = GY.Bill.Common.SaveUser();

            if (flag) {
                $("#btnSure").attr("data-check", 1);
                GY.Bill.Other.SaveBill();
            }
        });
    });
})();

